//
//  RootViewController.m
//  自定义控件
//
//  Created by LZXuan on 14-8-17.
//  Copyright (c) 2014年 LZXuan. All rights reserved.
//

#import "RootViewController.h"
#import "LZXLabel.h"
#import "LZXLabel2.h"
#import "LZXCustomImageView2.h"
#import "LZXCustomImageView.h"
#import "LZXButton.h"
@interface RootViewController ()

@end

@implementation RootViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
- (void)creatLabel{
    LZXLabel *label1 = [[LZXLabel alloc] initWithFrame:CGRectMake(110, 30, 100, 50)];
    
    label1.text = @"label1";
    label1.backgroundColor = [UIColor yellowColor];
    
    [label1 addTarget:self action:@selector(label1Click)];
    
    [self.view addSubview:label1];
    [label1 release];
    
    
    
    
    LZXLabel2 *label2 = [[LZXLabel2 alloc] initWithFrame:CGRectMake(110, 90, 100, 50)];
    
    label2.text = @"label2";
    label2.backgroundColor = [UIColor yellowColor];
    
    [label2 addTarget:self action:@selector(label2Click:)];
    label2.tag = 101;
    [self.view addSubview:label2];
    
    [label2 release];

}

- (void)creatImageView{
    
    LZXCustomImageView *imageView1 = [[LZXCustomImageView alloc] initWithFrame:CGRectMake(50, 150, 100, 200)];
    imageView1.image = [UIImage imageNamed:@"girl.jpg"];
    
    [imageView1 addTarget:self action:@selector(image1Click:)];
    [self.view addSubview:imageView1];
    [imageView1 release];
    
    
    LZXCustomImageView2 *imageView2 = [[LZXCustomImageView2 alloc] initWithFrame:CGRectMake(160, 150, 100, 200)];
    imageView2.image = [UIImage imageNamed:@"girl.jpg"];
    
    [imageView2 addTarget:self action:@selector(image2Click:)];
    [self.view addSubview:imageView2];
    [imageView2 release];

}
- (void)creatButtons{
    LZXButton *button = [LZXButton buttonWithType:UIButtonTypeSystem];
    [button setTitle:@"点我" forState:UIControlStateNormal];
    button.frame = CGRectMake(110, 400, 100, 50);
    
    [button addClickEventTouchUpInside:^(LZXButton *button) {
        NSLog(@"TouchUpInside事件");
    }];
    
    [button addClickEventTouchUpOutside:^(LZXButton *button) {
        NSLog(@"TouchUpOutside事件");
    }];
    
    [self.view addSubview:button];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor redColor];
    
    [self creatLabel];
    [self creatImageView];
    [self creatButtons];
}
- (void)image1Click:(LZXCustomImageView *)imageView{
    NSLog(@"image1Click柳岩被点击了");
}
- (void)image2Click:(LZXCustomImageView *)imageView{
    NSLog(@"image2Click柳岩2被点击了");
}

- (void)label1Click{
    NSLog(@"label1:被点击了");
}
- (void)label2Click:(LZXLabel2 *)label{
    NSLog(@"label2:被点击了,tag:%ld",label.tag);
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
